/*
 * Created by SharpDevelop.
 * User: Administrator
 * Date: 26-03-2009
 * Time: 11:54
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Collections.Generic;
using System.Web.UI;


namespace Plain.Utilities
{
	/// <summary>
	/// Description of QueryExtensions.
	/// </summary>
	public static class QueryExtensions{
		public static IEnumerable<T> findControl<T>(this Control o) where T : Control {
			IList<T> list = new List<T>();
			HandleObject<T>(o,list);
			return (list);
		}
		private static void HandleObject<T>(Control o,IList<T> list) where T: Control{
			if(o is T){
				list.Add((T)o);
			}
			foreach(Control  control in  o.Controls){
				HandleObject<T>(control,list);
			}
		}
	}
	
}
